<?php include_once './application/views/sys_admin/common/header.php';  ?>
<div class=" definewidth m20">
  	<form action="/sys_admin/borrow/<?php echo $func;?>" method="get" name="form0" id="form0" class="form-inline definewidth m20">
				标题：<input type="text" id="title" name="title" value="<?php echo $title?>" class="input_title" />
				
				<?php if($show !="going" && $show !="passing" && $show !="repayment" && $show !="full" ){?>		
	  			状态：<select id="fstatus" name="fstatus" class="select" >
	  				<option value="-2" <?php if($fstatus==-2){?>selected="selected"<?php }?>>所有</option>
	  				<?php foreach($borrow_status as $status_key => $status_value){?>
	  				<option value="<?php echo $status_key?>" <?php if($fstatus==$status_key){?>selected="selected"<?php }?>><?php echo $status_value;?></option>
	  				<?php }?>
	  			</select>
	  			<?php }?>
	  			计息方式：<select id="work_time" name="work_time" class="select" >
	  				<option value="0" <?php if($work_time==0){?>selected="selected"<?php }?>>所有</option>
	  				<?php foreach($borrow_work_time as $work_key=>$work_value){?>
	  				<option value="<?php echo $work_key?>" <?php if($work_time==$work_key){?>selected="selected"<?php }?>><?php echo $work_value;?></option>
	  				<?php }?>
	  			</select>
	  			
	  			还款方式：<select id="style" name="style" class="select" >
	  				<option value="0" <?php if($style==0){?>selected="selected"<?php }?>>所有</option>
	  				<?php foreach($borrow_style as $style_key=>$style_value){?>
	  				<option value="<?php echo $style_key?>" <?php if($style==$style_key){?>selected="selected"<?php }?>><?php echo $style_value;?></option>
	  				<?php }?>
	  			</select>
	  			
	  			<button type="button" class="btn btn-primary"  onclick="this.form.submit();" >查询</button>
	  	</form>		
		<table class="table table-bordered table-hover definewidth m10">
			 <thead>
			    <tr>
			        <th><strong>编号</strong></th>
					<th><strong>标的名称</strong></th>
					<th><strong>标的类型</strong></th>
					<th><strong>金额</strong></th>
					<th><strong>年利率</strong></th>
					<th><strong>标的期限</strong></th>
					<th><strong>计息方式</strong></th>
					<th><strong>最后还款日</strong></th>
					<th><strong>投资人数</strong></th>
					<?php if($show=='all'){?>
						<th><strong>审核进度</strong></th>
						<th><strong>标的状态</strong></th>
					<?php }elseif($show=='going'){?>
					<th><strong>投资进度</strong></th>
					<?php }else{?>
					<th><strong>完成借款天数</strong></th>
					<?php }?>				
					<th><strong>浏览次数</strong></th>
					<th><strong>还款方式</strong></th>
					<?php if($show !="going" && $show !="passing" && $show !="repayment"&&$show !="all"){?>
					<th><strong>操作</strong></th>
					<?php }?>
			    </tr>
			   </thead>
			      <?php foreach($borrow_list as $key => $borrow){?>
			  <tr>
				<td><a href="/sys_admin/borrow/borrow_view/<?php echo $borrow['id'];?>"><?php echo $borrow['id'];?></a></td>
				<td><a href="/sys_admin/borrow/borrow_view/<?php echo $borrow['id'];?>"><?php echo $borrow['title'];?></a></td>
				<td><?php echo $borrow_type[$borrow['ftype']];?></td>
				<td><?php echo number_format($borrow['account'],2);?></td>
				<td><?php echo $borrow['apr'];?>%</td>
				<td>
				<?php if($borrow['is_day'] == 1){
						echo $borrow['time_limit_day'].' 天';
					  }else{
					  	echo $borrow['time_limit'].' 个月';}?>
				</td>
				<td><?php echo $borrow_work_time[$borrow['work_time']];?></td>
				<td><?php echo date("Y-m-d",$borrow['each_time']);?></td>
				<td><?php echo $borrow['tender_times'];?></td>
				
					<?php if($show=='going'){?>
					<td>
						<span>
						<?php echo round($borrow['account_yes']/$borrow['account']*100);?>%
						</span>
					</td>
					<?php }elseif($show == 'all'){?>
					
				<?php  if($borrow['is_verify'] == 1 && $borrow['is_check']==1){?>
					<td>
						<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 1 && $borrow['is_check']==0){?>
					<td>
					<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 0 && $borrow['is_check']==0){?>
					<td>
					<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 2 && $borrow['is_check']==0){?>
					<td>
					<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 0 && $borrow['is_check']==1){?>
					<td>
						<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }elseif($borrow['is_verify'] == 0 && $borrow['is_check']==2){?>
					<td>
						<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
			  	<?php }elseif($borrow['is_verify'] == 1 && $borrow['is_check']==2){?>
					<td>
						<?php echo $borrow_verify[$borrow['is_verify']].' , '.$borrow_check[$borrow['is_check']];?></td>
				<?php }else{?>
					<td>
						未知进度</td>
				<?php }?>
				
				<td>
			  			<?php echo $borrow_status[$borrow['fstatus']];?> </td>
			  	<?php }else{?>
			  			<td>
			  			<?php echo intval($borrow['borrowing_days']);?>天 </td>
			  		<?php }?>	
			  		
				<td><?php echo $borrow['hits'];?></td>
				<td><?php echo $borrow_style[$borrow['style']];?></td>	
				
			  	<?php if($show !="going" && $show !="passing" && $show !="repayment"&& $show !="all"){?>		
				<td id="chebiao_<?php echo $borrow['id'];?>" >
					<?php if($borrow['fstatus'] == 0){?>
					<a href="/sys_admin/borrow/verify_view/<?php echo $borrow['id'];?>" target="_bank">审核</a>
					<a href="/sys_admin/borrow/edit_view/<?php echo $borrow['id'];?>" target="_bank">修改</a> 
					<?php }?>
					<?php if($borrow['fstatus'] == 1 && $borrow['account']==$borrow['account_yes']){?>
					<a href="/sys_admin/borrow/review_view/<?php echo $borrow['id'];?>">复审</a>
					<?php }?>					
					<?php if($borrow['fstatus'] < 1){?>
					<a href="javascript:if(confirm('你确定撤回？')){/sys_admin/borrow/withdraw(<?php echo $borrow['id'];?>);}">撤回</a>
					<?php }?>
				</td>
				
				<?php }?>
			  </tr>
			  <?php }?>
			  	<tr>
			  	<td colspan="14"  class="invbd_page"><?php echo $this->pagination->create_links();?></td>
			  	</tr>
		</table>
</div>

<div id="dialog" title="系统提示" style="display:none;">
<div id="msg" style="text-align:center;color:red">&nbsp;</div>

</div>

<script>
function withdraw(borrow_id){
	$.ajax({
		
		type: "get",
		url: "/sys_admin/borrow/withdraw/"+borrow_id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("撤标成功！");
				$("#chebiao_"+borrow_id).hide();
			}else{
				$("#msg").html("撤标失败，请联系管理员！");
			}
			setTimeout(function(){
				$("#dialog" ).dialog("close");
			},3000);
		},
		dataType: "text"
	});
}


</script>
